package Test;

import java.net.*;
import java.io.*;

class ServicerRead implements Runnable {
	public static byte MSG_START[] = { 0x0b, 0x02 };
	public static byte MSG_END[] = { 0x03, 0x1c };
	private Socket s;

	public ServicerRead(Socket s) {
		this.s = s;
	}

	public void run() {
		try {
			InputStream ips = s.getInputStream();
			BufferedInputStream bis;
			int ter = 0;
			bis = new BufferedInputStream(ips);
			int ch;
			while (true) {
				while ((ch = bis.read()) != 11) {
					System.out.print(ch + "----");
					if (ch == -1) {
						Thread.sleep(1000);
					}
				}
				System.out.println(ch + "outwhile000000000000000000000");
				if ((ch = bis.read()) == 2) {
					while (true) {
						if ((ch = bis.read()) != 3) {
							if (ch == -1) {
								System.out.println("END of EOF----");
								// System.exit(0);
								Thread.sleep(1000);
							}
							System.out.print(ch + "/t");
						} else {
							if ((ch = bis.read()) != 28) {
								System.out.print(3 + "/t" + ch + "/t");
								// System.out.println("not second end char");
							} else {
								System.out.println("END of correct" + ter);
								break;
							}
						}
					}
				}
				System.out.println("NEXT");
			}
			// ips.close();
			// ops.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

